package com.yy.invoice;


import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class Generator {
    public static void main(String[] args) {
        FastAutoGenerator.create("jdbc:mysql://yang1yu.site:3306/invoice?characterEncoding=utf-8&userSSL=false", "root", "yang1yu")
                .globalConfig(builder -> {
                    builder.author("yang1yu")
                            .fileOverride() // 覆盖已生成文件
                            .outputDir("E:\\generator"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.yy") // 设置父包名
                            .moduleName("invoices") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.mapperXml, "E:\\generator"));
                })
                .strategyConfig(builder -> {
                    builder.addInclude("user")
                            .addInclude("invoice"); // 设置需要生成的表名
//                                    .addTablePrefix("t_", "c_"); // 设置过滤表前缀
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker
                .execute();
    }
}